package com.zy.openchat.core.model.wallet;

import android.os.Parcel;
import android.os.Parcelable;

import com.ja.openchat.R;
import com.zy.openchat.core.model.remittance.RemittanceDetailInfo;
import com.zy.openchat.util.TimeConvertUtils;

public class WalletOrderInfo implements Parcelable {
    //类型 1.充值 2提现 3.收款 4.转账 5.创建红包 6.领取红包 7.红包退回
    public int type;
    public float amount;
    public String remarks;
    public long createAt;
    public WalletExtData extData;
    public long related;

    public String getTypeContent() {
        switch (type){
            case 1:
                return "充值";
            case 2:
                return "提现";
            case 3:
                return "收款";
            case 4:
                return "转账";
            case 5:
                return "创建红包";
            case 6:
                return "领取红包";
            case 7:
                return "红包退回";
            case 12:
                return "创建转账";
            case 13:
                return "领取转账";
            case 14:
                return "用户转账退款";
            case 15:
                return "系统转账退款";
            default:
                return "未知";
        }
    }

    public String getDate() {
        return TimeConvertUtils.formatDate9(createAt * 1000);
    }

    public String getAmount() {
        return amount >= 0 ? String.format("+￥%s", amount) : String.format("-￥%s", Math.abs(amount));
    }

    public int getColor() {
        return amount >= 0 ? R.color.me_nick_name_color_text_sub : R.color.color_fd4e57;
    }


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.type);
        dest.writeFloat(this.amount);
        dest.writeString(this.remarks);
        dest.writeLong(this.createAt);
        dest.writeParcelable(this.extData, flags);
        dest.writeLong(this.related);
    }

    public void readFromParcel(Parcel source) {
        this.type = source.readInt();
        this.amount = source.readFloat();
        this.remarks = source.readString();
        this.createAt = source.readLong();
        this.extData = source.readParcelable(WalletExtData.class.getClassLoader());
        this.related = source.readLong();
    }

    public WalletOrderInfo() {
    }

    protected WalletOrderInfo(Parcel in) {
        this.type = in.readInt();
        this.amount = in.readFloat();
        this.remarks = in.readString();
        this.createAt = in.readLong();
        this.extData = in.readParcelable(RemittanceDetailInfo.class.getClassLoader());
        this.related = in.readLong();
    }

    public static final Creator<WalletOrderInfo> CREATOR = new Creator<WalletOrderInfo>() {
        @Override
        public WalletOrderInfo createFromParcel(Parcel source) {
            return new WalletOrderInfo(source);
        }

        @Override
        public WalletOrderInfo[] newArray(int size) {
            return new WalletOrderInfo[size];
        }
    };
}
